﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ACAPM.Common;
using System.Configuration;

public partial class praisereports : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    private void ClearContactForm()
    {
        try
        {
            txtName.Text = string.Empty;
            txtAddress.Text = string.Empty;
            txtTelephone.Text = string.Empty;
            txtMobile.Text = string.Empty;
            txtEmail.Text = string.Empty;
            txtPrayerRequest.Text = string.Empty;
        }
        catch (Exception ex)
        {

        }
    }
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        try
        {
            lblStatus.Visible = true;

            Email mail = new Email();
            string body = "<br/><h1>Praise Report</h1><br/><b>From: </b>" + txtName.Text.Trim() + " (" + txtEmail.Text.Trim() + ") <br/><br/>" +
                "<b>Address: </b>" + txtAddress.Text.Trim() + "<br/><br/>" +
                "<b>Telephone #: </b>" + txtTelephone.Text.Trim() + "<br/><br/>" +
                "<b>Mobile #: </b>" + txtMobile.Text.Trim() + "<br/><br/>" +
                "<b>Email: </b>" + txtEmail.Text.Trim() + "<br/><br/>" +
                "<b>Praise Report: </b>" + txtPrayerRequest.Text.Trim(); //Server.HtmlDecode(txtPrayerRequest.Text.Trim());
            mail.Subject = "Praise Report from " + txtName.Text + "via ACAPM";
            mail.Body = body;
            mail.ToAddress = ConfigurationManager.AppSettings["ToAddressPraise"];

            if (EmailHelper.SendMail(mail))
            {
                divStatus.Attributes.Add("class", "notification success png_bg close");
                lblStatus.Text = "Your Praise Report has been received. All Glory be to GOD";

                ClearContactForm();

            }
            else
            {
                divStatus.Attributes.Add("class", "notification failure png_bg");
                lblStatus.Text = "There was an error in submitting your Praise Report. Please try again later or call us at 91 44 26703685.";
            }
        }
        catch (Exception ex)
        {

        }
    }
}